package com.imprenta.ejb;

import java.util.Collection;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;

import com.hibernate.util.HibernateUtil;
import com.imprenta.entities.Menu;

public class EjbMenu {
	
	@SuppressWarnings("unchecked")
	public static Collection<Menu> getMenu(){
		
		Session session = HibernateUtil.getSessionFactory().openSession();
		Collection<Menu> list = null;
		try {
			String q = "from Menu m order by m.menuid asc, orden asc";
			Query query = session.createQuery(q);
			list = query.list();			
					
		} catch (HibernateException he) {
			he.printStackTrace();
		}catch (Exception e) {
			e.printStackTrace();
		}
		finally{
			if (session != null) {
				session.close();
			}
		}
		return list;
	}//fin getmenu

}
